package com.tian.auto;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.PrintStream;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * 日志输出工具
 */
public class Log {


    public static PrintStream printStream;

    public static void info(String tag, String msg) {
        //将日志输出到文件中，不再在 控制台显示
//        if (printStream == null) {
//            try {
//                File logFile = new File("/Users/tianjinyong/Desktop/work/international/doc/log.txt");
//
//                if (!logFile.exists()) {
//                    logFile.createNewFile();
//                }
//                printStream = new PrintStream(logFile);
//            } catch (Exception e) {
//                e.printStackTrace();
//            }
//
//            System.setOut(printStream);
//        }

        System.out.println(getCurrentTime() + "-[" + tag + "]  " + msg);
    }

    private static String getCurrentTime() {
        SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
        return sf.format(new Date(System.currentTimeMillis()));
    }

}
